package com.woniu.darryringmall.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniu.darryringmall.admin.entity.Manager;
import com.woniu.darryringmall.admin.entity.Perm;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 管理员mapper
 */
public interface ManagerMapper extends BaseMapper<Manager> {
    @Select("select * from mall_manager where account = #{account}")
    Manager getByAccount(String account);

    @Select("SELECT p.* FROM mall_manager_perm mp, mall_perm p WHERE #{id} = mp.managerid AND mp.permid = p.id" +
            " union " +
            "SELECT p.* FROM mall_manager_role mr, mall_role r, mall_role_perm rp, mall_perm p " +
            "WHERE #{id} = mr.managerid and mr.roleid = r.id and r.id = rp.roleid and rp.permid = p.id")
    List<Perm> getPermsByManagerId(int id);
}
